package com.platform.web.controller.module;

import java.util.List;
import com.platform.framework.util.ShiroUtils;
import com.platform.module.service.IBaseRoomTempService;
import com.platform.system.service.ISysDictDataService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.platform.common.annotation.Log;
import com.platform.common.enums.BusinessType;
import com.platform.module.domain.ValveRecord;
import com.platform.module.service.IValveRecordService;
import com.platform.common.core.controller.BaseController;
import com.platform.common.core.domain.AjaxResult;
import com.platform.common.utils.poi.ExcelUtil;
import com.platform.common.core.page.TableDataInfo;

/**
 * 阀门数据记录Controller
 * 
 * @author wangqi
 * @date 2020-07-24
 */
@Controller
@RequestMapping("/module/valve/record")
public class ValveRecordController extends BaseController
{
    private String prefix = "module/valve/record";

    @Autowired
    private IValveRecordService valveRecordService;

    @RequiresPermissions("module:valve:record:view")
    @GetMapping("/{valveId}")
    public String record(@PathVariable("valveId") String valveId, ModelMap mmap)
    {
        if(valveId.equals("0")){
            valveId = "";
        }
        mmap.put("valveId",valveId);
        return prefix + "/record";
    }

    /**
     * 查询阀门数据记录列表
     */
    @RequiresPermissions("module:valve:record:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ValveRecord valveRecord)
    {
        startPage();
        List<ValveRecord> list = valveRecordService.selectValveRecordList(valveRecord);
        return getDataTable(list);
    }

    /**
     * 导出阀门数据记录列表
     */
    @RequiresPermissions("module:valve:record:export")
    @Log(title = "阀门数据记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ValveRecord valveRecord)
    {
        List<ValveRecord> list = valveRecordService.selectValveRecordList(valveRecord);
        ExcelUtil<ValveRecord> util = new ExcelUtil<ValveRecord>(ValveRecord.class);
        return util.exportExcel(list, "record");
    }
}
